package test.socket;

import java.net.DatagramPacket;

import org.junit.Test;

import hyl.base.net.udp.UdpData;
import hyl.base.net.udp.UdpService;
import hyl.core.MyFun;
import hyl.core.net.MyUdp;
import hyl.core.safe.MyBase64;

public class testUdpserver {
	public static void main(String [] arg) {
		new testUdpserver(). test1_3();  //test1_2() ;
		
		
	}
	//@Test
	public void test1() {
		
		UdpService userver=new UdpService(8989);
		userver.listen();
		UdpData data=  userver.pull();
		String s=MyBase64.encode(data.getData());
		System.out.println(s);
	}

	public void test1_2() {
		MyUdp udp=new MyUdp(90);		
		udp.receive((dp)->{
			DatagramPacket rp =dp;
			MyFun.print(MyFun.bytes2U8str(rp.getData()),
			rp.getLength(),
			rp.getOffset());
			
			
			return false;
		});
	}
	
	public void test1_3() {
		MyUdp udp=new MyUdp(90);	
	//	udp.set接收缓存(10);
		udp.receive((dp)->{
			DatagramPacket rp =dp;
			MyFun.print(
			rp.getLength(),
			rp.getOffset());
			
			
			return false;
		});
	}
}
